#!/bin/sh

# 项目名称
PROJECT_NAME=HYSurveySDKXLib

# 框架名称
framework_name=$PROJECT_NAME

# 指定工作区
workspace_name="${framework_name}.xcodeproj/project.xcworkspace"

# 输出路径
output_path=./build/${framework_name}

# 模拟器和真机的存档路径
simulator_archive_path=$output_path/simulator.xcarchive
iOS_device_archive_path=$output_path/iOS.xcarchive

# 清理旧的输出
rm -r $output_path
mkdir $output_path

# 打包模拟器
xcodebuild archive \
-workspace $workspace_name \
-scheme $framework_name \
-destination "generic/platform=iOS Simulator" \
-archivePath $simulator_archive_path \
SKIP_INSTALL=NO

# 打包真机
xcodebuild archive \
-workspace $workspace_name \
-scheme $framework_name \
-destination "generic/platform=iOS" \
-archivePath $iOS_device_archive_path \
SKIP_INSTALL=NO

# 创建 xcframework
xcodebuild -create-xcframework \
-framework $simulator_archive_path/Products/Library/Frameworks/$framework_name.framework \
-framework $iOS_device_archive_path/Products/Library/Frameworks/$framework_name.framework \
-output $output_path/$framework_name.xcframework
